package com.vhall.component.dao.room;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.vhall.component.entity.room.entity.RoomJoinsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @author rui.zhou
 * @date 2021/4/21 11:46
 */
@Mapper
@Repository
public interface RoomJoinsMapper extends BaseMapper<RoomJoinsEntity> {

    /**
     * 根据房间id和用户id查询信息
     *
     * @param roomId
     * @param accountId
     * @return
     */
    @Select("select * from room_joins where room_id=#{roomId} and account_id=#{accountId}  ")
    RoomJoinsEntity getRoomJoins(@Param("roomId") String roomId, @Param("accountId") Integer accountId);

    @Select("select count(distinct account_id) from room_joins ${ew.customSqlSegment} ")
    Integer selectDistinctAccountCount(@Param(Constants.WRAPPER) Wrapper<RoomJoinsEntity> queryWrapper);
}
